/**
 * 获取WebGL上下文对象
 * @param {canvas元素id} selector 
 */
function createGLContext(selector){
    var canvas = document.querySelector(selector);
    if(canvas == null){
        throw new Error("canvas元素获取失败");
    }
    var names = ["webgl", "experimental-webgl"];
    var context = null;
    for(var i=0;i<names.length;i++){
        try{
            context = canvas.getContext(names[i]);
        }catch(e){
            if(context){
                break;
            }
        }
    }

    if(context){
        context.viewportWidth = canvas.width;
        context.viewportHeight = canvas.height;
    }else{
        console.log("创建WebGL对象上下文失败!");
    }
    return context;
}
export { createGLContext };